//
//  BasicNavigationController.m
//  test
//
//  Created by kepuG on 17/1/19.
//  Copyright © 2017年 text. All rights reserved.
//

#import "BasicNavigationController.h"

@interface BasicNavigationController ()

@property (strong, nonatomic) UIView *navLine;

@end

@implementation BasicNavigationController



-(void)viewWillAppear:(BOOL)animated{
    
    [super viewWillAppear:animated];
    //藏旧
    [self hideBorderInView:self.navigationBar];
    //添加新的
    if (_navLine == nil) {
        _navLine = [[UIView alloc]initWithFrame:CGRectMake(0, 44, kScreen_Width, 1.0/ [UIScreen mainScreen].scale)];
        _navLine.backgroundColor = kColorCCC;
        [self.navigationBar addSubview:_navLine];
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

-(void) hiddeNavBottomLine{
    
    [self hideBorderInView:self.navigationBar];
    _navLine.hidden = YES;
}

-(void)showNavBottomLine{
    _navLine.hidden = NO;
}


- (void) hideBorderInView:(UIView*)view {
    
    if ([view isKindOfClass:[UIImageView class]] &&
        view.frame.size.height <= 1) {
        view.hidden = YES;
    }
    for (UIView *subView in view.subviews) {
        [self hideBorderInView:subView];
    }
}

-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    
    if (self.viewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:animated];
}


-(BOOL)shouldAutorotate{
    return [self.visibleViewController shouldAutorotate];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
